package standard;

import java.awt.Color;

import net.ByteBuffer;
import net.ByteReader;
import core.Entity;
import core.ViewableEntity;

public class PlayerEntity extends ViewableEntity {

	/**
	 * The color of this entity.
	 */
	public Color color;

	public PlayerEntity() {
	}

	public PlayerEntity(Color color) {
		this.color = color;
	}

	@Override
	public void readAttributes(ByteReader reader) {
		super.readAttributes(reader);
		int r = reader.read() + 128;
		int g = reader.read() + 128;
		int b = reader.read() + 128;
		color = new Color(r, g, b);
	}

	@Override
	protected void readAttributes(Entity e) {
		super.readAttributes(e);
		PlayerEntity p = (PlayerEntity) e;
		color = p.color;
	}

	@Override
	protected void writeAttributes(ByteBuffer buffer) {
		super.writeAttributes(buffer);
		buffer.add(color.getRed() - 128);
		buffer.add(color.getGreen() - 128);
		buffer.add(color.getBlue() - 128);
	}

	@Override
	public Class<?> getChildClass() {
		return this.getClass();
	}

	@Override
	public short getHeight() {
		return 32;
	}

	@Override
	public short getWidth() {
		return 32;
	}

}
